import math
import numpy as np


class BasisFuction:
    def __init__(self, n, h, s):
        self.n = n
        self.h = h
        self.s = s

    def construct(self):
        I_2 = np.identity(2)
        G_i = np.zeros((self.n, 2, 2*(2*self.h+1)))
        for j in range(self.n):
            g_h = np.array([[[math.cos(math.pi*2*i*self.s[j]), math.sin(math.pi*2*i*self.s[j]), 0, 0], 
                [0, 0, math.cos(math.pi*2*i*self.s[j]), math.sin(math.pi*2*i*self.s[j])]] for i in range(1, self.h+1)])
            g = np.hstack([g_h[i] for i in range(self.h)])
            G_i[j] = np.hstack([g, I_2])
        return G_i